const ProjectModel=require('../moduls/project')
// const uuidv1 = require('uuid/v1');
const statusCode=require('../util/status-code')

class ProjectController{
  static async list(ctx){
    try {
      let uuid=ctx.params.uuid
      const list=await ProjectModel.list(uuid)
      ctx.body=statusCode.s200(list)
    }catch (e) {
      ctx.body=statusCode.e412(e)
    }
  }
  static async create(ctx){
    try{
      let body=ctx.request.body
      let uuid=ctx.params.uuid
      body={
        ...body,
        uuid
      }
      await ProjectModel.creat(body)
      ctx.body=statusCode.s200(body)
    }catch (e) {
      ctx.body=statusCode.e412(e)
    }
  }
  static async detail(ctx){
    try{
      let id=ctx.params.id
      const res=await ProjectModel.detail(id)
      ctx.body=statusCode.s200(res)
    }catch (e) {

    }
  }
  static async update(ctx){
    try{
      let body=ctx.request.body
      let id=ctx.params.id
      await ProjectModel.update(id,body)
      ctx.body=statusCode.s200(id)
    }catch (e) {

    }
  }
  static async del(ctx){
    try{
      let id=ctx.params.id
      await ProjectModel.del(id)
      ctx.body=statusCode.s200(id)
    }catch (e) {

    }
  }
  static async level(ctx){
    try{
      let body=ctx.request.body
      await ProjectModel.level(body)
      ctx.body=statusCode.s200(body)
    }catch (e) {

    }
  }
}


module.exports = ProjectController